/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication1;

/**
 *
 * @author Administrator
 */
public class NewJFrame extends javax.swing.JFrame {

    /**
     * Creates new form NewJFrame
     */
    public NewJFrame() {
         initComponents(); 
         sp.listPort();
         sp.jTshow=jTcmd;
         sp.jTlog=jTlog;
         jTlog.append(sp.strBlog.toString());
         sp.strBlog.delete(0, sp.strBlog.length());
         jCcom.removeAllItems();
         for(int i=0;i<sp.listPort.size();i++)
         {
             jCcom.addItem(sp.listPort.get(i).toString());
         }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTcmd = new javax.swing.JTextArea();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jBselect = new javax.swing.JButton();
        jBreadfile = new javax.swing.JButton();
        jBreadrec = new javax.swing.JButton();
        jBreadcash = new javax.swing.JButton();
        jBselcash = new javax.swing.JButton();
        jBReadEP = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jBGetChallenge = new javax.swing.JButton();
        jBExternalAuthentication = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jCcom = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        jBOpen = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jBaddcmd = new javax.swing.JButton();
        jBcancel = new javax.swing.JButton();
        jBauto = new javax.swing.JButton();
        jBstep = new javax.swing.JButton();
        jToolBar1 = new javax.swing.JToolBar();
        jBLoadcmd = new javax.swing.JButton();
        jBSavecmd = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JToolBar.Separator();
        jBSavelog = new javax.swing.JButton();
        jBclear = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JToolBar.Separator();
        jBDESMACAns = new javax.swing.JButton();
        jSeparator11 = new javax.swing.JToolBar.Separator();
        jBRSAcal = new javax.swing.JButton();
        jSeparator5 = new javax.swing.JToolBar.Separator();
        jBTlvAns = new javax.swing.JButton();
        jSeparator9 = new javax.swing.JToolBar.Separator();
        jB8583bitmap = new javax.swing.JButton();
        jSeparator7 = new javax.swing.JToolBar.Separator();
        jBt_8583ans = new javax.swing.JButton();
        jSeparator8 = new javax.swing.JToolBar.Separator();
        jBcutpic = new javax.swing.JButton();
        jSeparator6 = new javax.swing.JToolBar.Separator();
        jBTCPtool = new javax.swing.JButton();
        jSeparator10 = new javax.swing.JToolBar.Separator();
        jBt_calc = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JToolBar.Separator();
        jButton11 = new javax.swing.JButton();
        jSeparator4 = new javax.swing.JToolBar.Separator();
        jButton12 = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTlog = new javax.swing.JTextArea();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("卡片测试工具V1.0");

        jTcmd.setColumns(20);
        jTcmd.setLineWrap(true);
        jTcmd.setRows(5);
        jScrollPane1.setViewportView(jTcmd);

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "ID", "命令", "命令注释"
            }
        ));
        jTable1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jScrollPane2.setViewportView(jTable1);

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("读操作相关指令"));

        jBselect.setText("选文件");
        jBselect.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBselectActionPerformed(evt);
            }
        });

        jBreadfile.setText("读文件");
        jBreadfile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBreadfileActionPerformed(evt);
            }
        });

        jBreadrec.setText("读记录");
        jBreadrec.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBreadrecActionPerformed(evt);
            }
        });

        jBreadcash.setText("读余额");
        jBreadcash.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBreadcashActionPerformed(evt);
            }
        });

        jBselcash.setText("选现金");
        jBselcash.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBselcashActionPerformed(evt);
            }
        });

        jBReadEP.setText("读钱包");
        jBReadEP.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBReadEPActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jBReadEP, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jBreadfile, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE)
                        .addComponent(jBreadrec, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE)
                        .addComponent(jBselcash, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE))
                    .addComponent(jBselect, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jBreadcash, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(jBselect, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jBreadfile, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jBreadrec, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jBReadEP, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jBselcash, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jBreadcash)
                .addContainerGap(12, Short.MAX_VALUE))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("写操作相关指令"));

        jButton1.setText("写记录");

        jButton6.setText("写文件");

        jBGetChallenge.setText("取随机数");
        jBGetChallenge.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBGetChallengeActionPerformed(evt);
            }
        });

        jBExternalAuthentication.setText("外部验证");
        jBExternalAuthentication.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBExternalAuthenticationActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jBExternalAuthentication, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jBGetChallenge, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jBGetChallenge)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jBExternalAuthentication)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton6)
                .addContainerGap(14, Short.MAX_VALUE))
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jCcom.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel1.setText("串口");

        jBOpen.setText("打开串口");
        jBOpen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBOpenActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jBOpen, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jCcom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jCcom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addGap(10, 10, 10)
                .addComponent(jBOpen)
                .addContainerGap(145, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(77, 77, 77))
        );

        jTabbedPane1.addTab("通用指令", jPanel1);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jBaddcmd.setText("增加指令");
        jBaddcmd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBaddcmdActionPerformed(evt);
            }
        });

        jBcancel.setText("删除指令");
        jBcancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBcancelActionPerformed(evt);
            }
        });

        jBauto.setText("自动执行");
        jBauto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBautoActionPerformed(evt);
            }
        });

        jBstep.setText("单步执行");
        jBstep.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBstepActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addComponent(jBstep, javax.swing.GroupLayout.DEFAULT_SIZE, 179, Short.MAX_VALUE)
                .addGap(39, 39, 39)
                .addComponent(jBauto, javax.swing.GroupLayout.DEFAULT_SIZE, 179, Short.MAX_VALUE)
                .addGap(39, 39, 39)
                .addComponent(jBcancel, javax.swing.GroupLayout.DEFAULT_SIZE, 179, Short.MAX_VALUE)
                .addGap(39, 39, 39)
                .addComponent(jBaddcmd, javax.swing.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jBaddcmd)
                    .addComponent(jBcancel)
                    .addComponent(jBauto)
                    .addComponent(jBstep))
                .addGap(0, 0, Short.MAX_VALUE))
        );

        jToolBar1.setRollover(true);

        jBLoadcmd.setText("加载指令");
        jBLoadcmd.setFocusable(false);
        jBLoadcmd.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jBLoadcmd.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jBLoadcmd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBLoadcmdActionPerformed(evt);
            }
        });
        jToolBar1.add(jBLoadcmd);

        jBSavecmd.setText("保存指令");
        jBSavecmd.setFocusable(false);
        jBSavecmd.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jBSavecmd.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jBSavecmd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBSavecmdActionPerformed(evt);
            }
        });
        jToolBar1.add(jBSavecmd);
        jToolBar1.add(jSeparator3);

        jBSavelog.setText("保存日志");
        jBSavelog.setFocusable(false);
        jBSavelog.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jBSavelog.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jBSavelog.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBSavelogActionPerformed(evt);
            }
        });
        jToolBar1.add(jBSavelog);

        jBclear.setText("清空显示");
        jBclear.setFocusable(false);
        jBclear.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jBclear.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jBclear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBclearActionPerformed(evt);
            }
        });
        jToolBar1.add(jBclear);
        jToolBar1.add(jSeparator1);

        jBDESMACAns.setText("DES/MAC计算");
        jBDESMACAns.setFocusable(false);
        jBDESMACAns.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jBDESMACAns.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jBDESMACAns.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBDESMACAnsActionPerformed(evt);
            }
        });
        jToolBar1.add(jBDESMACAns);
        jToolBar1.add(jSeparator11);

        jBRSAcal.setText("RSA计算");
        jBRSAcal.setFocusable(false);
        jBRSAcal.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jBRSAcal.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jBRSAcal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBRSAcalActionPerformed(evt);
            }
        });
        jToolBar1.add(jBRSAcal);
        jToolBar1.add(jSeparator5);

        jBTlvAns.setText("TLV解析");
        jBTlvAns.setFocusable(false);
        jBTlvAns.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jBTlvAns.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jBTlvAns.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBTlvAnsActionPerformed(evt);
            }
        });
        jToolBar1.add(jBTlvAns);
        jToolBar1.add(jSeparator9);

        jB8583bitmap.setText("8583位图");
        jB8583bitmap.setFocusable(false);
        jB8583bitmap.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jB8583bitmap.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jB8583bitmap.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jB8583bitmapActionPerformed(evt);
            }
        });
        jToolBar1.add(jB8583bitmap);
        jToolBar1.add(jSeparator7);

        jBt_8583ans.setText("8583解析");
        jBt_8583ans.setFocusable(false);
        jBt_8583ans.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jBt_8583ans.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jBt_8583ans.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBt_8583ansActionPerformed(evt);
            }
        });
        jToolBar1.add(jBt_8583ans);
        jToolBar1.add(jSeparator8);

        jBcutpic.setText("截图");
        jBcutpic.setFocusable(false);
        jBcutpic.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jBcutpic.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jBcutpic.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBcutpicActionPerformed(evt);
            }
        });
        jToolBar1.add(jBcutpic);
        jToolBar1.add(jSeparator6);

        jBTCPtool.setText("TCP工具");
        jBTCPtool.setFocusable(false);
        jBTCPtool.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jBTCPtool.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jBTCPtool.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBTCPtoolActionPerformed(evt);
            }
        });
        jToolBar1.add(jBTCPtool);
        jToolBar1.add(jSeparator10);

        jBt_calc.setText("计算器");
        jBt_calc.setFocusable(false);
        jBt_calc.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jBt_calc.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jBt_calc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBt_calcActionPerformed(evt);
            }
        });
        jToolBar1.add(jBt_calc);
        jToolBar1.add(jSeparator2);

        jButton11.setText("帮助");
        jButton11.setFocusable(false);
        jButton11.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton11.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(jButton11);
        jToolBar1.add(jSeparator4);

        jButton12.setText("退出");
        jButton12.setFocusable(false);
        jButton12.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton12.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(jButton12);

        jTlog.setColumns(20);
        jTlog.setRows(5);
        jScrollPane3.setViewportView(jTlog);

        jMenu1.setText("File");
        jMenuBar1.add(jMenu1);

        jMenu2.setText("Edit");
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(6, 6, 6)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jScrollPane1)
                    .addComponent(jScrollPane2)
                    .addComponent(jScrollPane3)))
            .addGroup(layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 865, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 208, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 654, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jBstepActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBstepActionPerformed
        // TODO add your handling code here:
        //jTcmd.setText("button clicked");
        int j=jTable1.getSelectedRow();
        if((j>=0)&&(j<JDialogSelect.tbindex))
        {
            if(jTable1.getModel().getValueAt(j, 1).equals(""))
            {}
            else
            {
                 if(sp.portState)
                 {
                    sp.write(jTable1.getModel().getValueAt(j, 1).toString());
                    jTlog.append("-->发送成功!\r\n");
                   // jTcmd.setForeground(Color.GREEN);
                    jTcmd.append(jTable1.getModel().getValueAt(j, 2).toString()+"\r\n");
                    jTcmd.append(jTable1.getModel().getValueAt(j, 1).toString()+"\r\n");
                    
                 }
                 else
                 {
                    jTlog.append("-->串口未打开，发送失败!\r\n");       
                 }
                 jTable1.addRowSelectionInterval(j+1,0);
                 jTable1.removeRowSelectionInterval(j,0);

                 
            }
        }
             
    }//GEN-LAST:event_jBstepActionPerformed

    private void jBaddcmdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBaddcmdActionPerformed
        // TODO add your handling code here:
        JDialogAddcmd dl=new JDialogAddcmd(this,true);
        dl.setSize(250, 240);
        dl.setVisible(true);
       if(dl.returnStatus==JDialogAddcmd.RET_OK)
       {
           //jTable1.
           jTable1.getModel().setValueAt(JDialogSelect.tbindex, JDialogSelect.tbindex, 0);
           jTable1.getModel().setValueAt(dl.jTcmd.getText(), JDialogSelect.tbindex, 1);
           jTable1.getModel().setValueAt("添加指令--"+dl.jTzhushi.getText(), JDialogSelect.tbindex, 2);
           JDialogSelect.tbindex++;
          // jTlog.append("-->OK按钮按下!\r\n");
       }
    }//GEN-LAST:event_jBaddcmdActionPerformed

    private void jBcancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBcancelActionPerformed
        // TODO add your handling code here:
        int i,j=jTable1.getSelectedRow();
        if(j>=0)
        {
            //JDialogSelect.tbindex--;
            if(JDialogSelect.tbindex>j)
            {
                 for(i=j;i<JDialogSelect.tbindex-1;i++)
                 {
                     jTable1.getModel().setValueAt(jTable1.getModel().getValueAt(j, 0), j, 0); 
                     jTable1.getModel().setValueAt(jTable1.getModel().getValueAt(j+1, 1), j, 1);
                     jTable1.getModel().setValueAt(jTable1.getModel().getValueAt(j+1, 2), j, 2);
                 }
                 jTable1.getModel().setValueAt("", JDialogSelect.tbindex-1, 0); 
                 jTable1.getModel().setValueAt("", JDialogSelect.tbindex-1, 1);
                 jTable1.getModel().setValueAt("", JDialogSelect.tbindex-1, 2);
                 JDialogSelect.tbindex--;
                 
            }
        }
    }//GEN-LAST:event_jBcancelActionPerformed

    private void jBautoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBautoActionPerformed
        // TODO add your handling code here:
        new Thread()
        {
            public void run()
            {
               try 
               {
                  int i,j=jTable1.getSelectedRow();
                  if(j==-1) j=0;
                  if((j>=0)&&(j<JDialogSelect.tbindex))
                  {
                       for(i=j;i<=JDialogSelect.tbindex-1;i++)
                       {
                           if(jTable1.getModel().getValueAt(i, 1).equals(""))
                            { continue;}
                           if(sp.portState)
                            {
                               sp.write(jTable1.getModel().getValueAt(i, 1).toString());
                               jTlog.append("-->发送成功!\r\n");
                               jTcmd.append(jTable1.getModel().getValueAt(i, 2).toString()+"\r\n");
                               jTcmd.append(jTable1.getModel().getValueAt(i, 1).toString()+"\r\n");
                               jTcmd.setCaretPosition(jTcmd.getText().length());
                               jTable1.addRowSelectionInterval(i+1,0);
                               jTable1.removeRowSelectionInterval(i,0);
                               Thread.sleep(500);
                            }
                            else
                            {
                               jTlog.append("-->串口未打开，发送失败!\r\n");       
                            }
                       }
                  }
               } catch (InterruptedException e) { }
            }
        }.start(); 
        
    }//GEN-LAST:event_jBautoActionPerformed

    private void jBOpenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBOpenActionPerformed
        // TODO add your handling code here:
        if(jBOpen.getText()=="打开串口")
        {
            if(jCcom.getItemCount()!=0)
            {
                if(true==sp.selectPort(jCcom.getSelectedItem().toString()))
                {
                    //                    sp.write("210.36.16.166");
                    //                    sp.write("2");
                    //                    sp.startRead(120);
                    sp.portState=true;
                    sp.startRead(0);
                    jTlog.append(sp.strBlog.toString());
                    jBOpen.setText("关闭串口");
                }
                else
                {
                    jBOpen.setText("打开串口");
                    sp.portState=false;
                    javax.swing.JOptionPane.showMessageDialog(null , "串口打开失败!" ,"提示" , javax.swing.JOptionPane.ERROR_MESSAGE) ;
                }

            }
            else
            {
                javax.swing.JOptionPane.showMessageDialog(null , "未选择串口!" ,"提示" , javax.swing.JOptionPane.ERROR_MESSAGE) ;
                sp.portState=false;
            }
        }
        else
        {
            sp.close();
            sp.portState=false;
            jBOpen.setText("打开串口");
            jTlog.append("-->串口已关闭!\r\n");
        }

    }//GEN-LAST:event_jBOpenActionPerformed

    private void jBreadrecActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBreadrecActionPerformed
        // TODO add your handling code here:
        JDialogReadRec dl=new JDialogReadRec(this,true);
        dl.setSize(320, 280);
        dl.setVisible(true);
        if(dl.returnStatus==JDialogSelect.RET_OK)
        {
            String str="00B2";
            int i,j,k;
            i=Integer.parseInt(dl.jTnumber.getText());
            str+= String.format("%02x", i);
            i=Integer.parseInt(dl.jTsfi.getText());
            i=((0x04|(i<<3)&0xF8));
            str+= String.format("%02x", i);
            i=Integer.parseInt(dl.jTlen.getText());
            str+= String.format("%02x", i);
            jTable1.getModel().setValueAt(JDialogSelect.tbindex, JDialogSelect.tbindex, 0);
            jTable1.getModel().setValueAt(str.toUpperCase(), JDialogSelect.tbindex, 1);
            jTable1.getModel().setValueAt("通用指令--读取记录文件"+dl.jTsfi.getText()+"-"+dl.jTnumber.getText(), JDialogSelect.tbindex, 2);
            JDialogSelect.tbindex++;
            if(Integer.parseInt(dl.jTRecnum.getText())>1)
            {
                j=Integer.parseInt(dl.jTRecnum.getText());
                i=Integer.parseInt(dl.jTnumber.getText());
                j+=i;
                i+=1;
                for(k=i;k<j;k++)
                {
                    str="00B2";
                    str+= String.format("%02x", k);
                    i=Integer.parseInt(dl.jTsfi.getText());
                    i=((0x04|(i<<3)&0xF8));
                    str+= String.format("%02x", i);
                    i=Integer.parseInt(dl.jTlen.getText());
                    str+= String.format("%02x", i);
                    jTable1.getModel().setValueAt(JDialogSelect.tbindex, JDialogSelect.tbindex, 0);
                    jTable1.getModel().setValueAt(str.toUpperCase(), JDialogSelect.tbindex, 1);
                    jTable1.getModel().setValueAt("通用指令--读取记录文件"+dl.jTsfi.getText()+"-"+k, JDialogSelect.tbindex, 2);
                    JDialogSelect.tbindex++;    
                }
                 
                
            }
        }
    }//GEN-LAST:event_jBreadrecActionPerformed

    private void jBreadfileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBreadfileActionPerformed
        // TODO add your handling code here:
        JDialogReadFile dl=new JDialogReadFile(this,true);
        dl.setSize(320, 280);
        dl.setVisible(true);
        if(dl.returnStatus==JDialogSelect.RET_OK)
        {
            //jTable1.
            String str;
            int i;
            str="00B0";
            // str+=dl.jTSFI.getText();

            i=Integer.parseInt(dl.jTsfi.getText());
            i=((i&0x1F)|0x80);
            str+= String.format("%02x", i);
            i=Integer.parseInt(dl.jToffset.getText());
            str+= String.format("%02x", i);
            i=Integer.parseInt(dl.jTlen.getText());
            str+=String.format("%02x", i);
            jTable1.getModel().setValueAt(JDialogSelect.tbindex, JDialogSelect.tbindex, 0);
            jTable1.getModel().setValueAt(str.toUpperCase(), JDialogSelect.tbindex, 1);
            jTable1.getModel().setValueAt("通用指令--读取二进制文件"+dl.jTsfi.getText(), JDialogSelect.tbindex, 2);
            JDialogSelect.tbindex++;
            // jTlog.append("-->OK按钮按下!\r\n");
        }
    }//GEN-LAST:event_jBreadfileActionPerformed

    private void jBselectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBselectActionPerformed
        // TODO add your handling code here:
        JDialogSelect dl=new JDialogSelect(this,true);
        dl.setSize(320, 280);
        dl.setVisible(true);
        if(dl.returnStatus==JDialogSelect.RET_OK)
        {
            //jTable1.
            String str="",str1="";
            if(dl.jRb1.isSelected())//AID
            {
                str="00A40400";
                if(dl.jCB1.isSelected())
                {
                    str1=String.format("%02d",dl.jTAID.getText().length()/2);
                    str+=str1;
                    str+=dl.jTAID.getText();
                }
                else
                {
                    str1=String.format("%02x",dl.jTAID.getText().length());
                    str+=str1;
                    char[] arr=dl.jTAID.getText().toCharArray();
                    int i,j,len=dl.jTAID.getText().length();
                    for(i=0;i<len;i++)
                    {
                       j= arr[i];
                       str+=String.format("%02x",j);
                    }    
                }
               jTable1.getModel().setValueAt(JDialogSelect.tbindex, JDialogSelect.tbindex, 0);
               jTable1.getModel().setValueAt(str.toUpperCase(), JDialogSelect.tbindex, 1);
               jTable1.getModel().setValueAt("通用指令--选择文件"+dl.jTAID.getText(), JDialogSelect.tbindex, 2);
               JDialogSelect.tbindex++;
               
            }
            else
            {
                str="00A4000002";
                str+=dl.jTSFI.getText();
                jTable1.getModel().setValueAt(JDialogSelect.tbindex, JDialogSelect.tbindex, 0);
                jTable1.getModel().setValueAt(str.toUpperCase(), JDialogSelect.tbindex, 1);
                jTable1.getModel().setValueAt("通用指令--选择文件"+dl.jTSFI.getText(), JDialogSelect.tbindex, 2);
                JDialogSelect.tbindex++;
            }
           
            // jTlog.append("-->OK按钮按下!\r\n");
        }

    }//GEN-LAST:event_jBselectActionPerformed

    private void jBselcashActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBselcashActionPerformed
        // TODO add your handling code here:
         jTable1.getModel().setValueAt(JDialogSelect.tbindex, JDialogSelect.tbindex, 0);
         jTable1.getModel().setValueAt("00A404000E325041592E5359532E4444463031", JDialogSelect.tbindex, 1);
         jTable1.getModel().setValueAt("通用指令--选择QPBOC应用", JDialogSelect.tbindex, 2);
         JDialogSelect.tbindex++;
         jTable1.getModel().setValueAt(JDialogSelect.tbindex, JDialogSelect.tbindex, 0);
         jTable1.getModel().setValueAt("00A4040008A000000333010101", JDialogSelect.tbindex, 1);
         jTable1.getModel().setValueAt("通用指令--选择电子现金AID", JDialogSelect.tbindex, 2);
         JDialogSelect.tbindex++;
    }//GEN-LAST:event_jBselcashActionPerformed

    private void jBreadcashActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBreadcashActionPerformed
        // TODO add your handling code here:
         jTable1.getModel().setValueAt(JDialogSelect.tbindex, JDialogSelect.tbindex, 0);
         jTable1.getModel().setValueAt("80CA9F7900", JDialogSelect.tbindex, 1);
         jTable1.getModel().setValueAt("通用指令--读电子现金余额", JDialogSelect.tbindex, 2);
         JDialogSelect.tbindex++;
         jTable1.getModel().setValueAt(JDialogSelect.tbindex, JDialogSelect.tbindex, 0);
         jTable1.getModel().setValueAt("80A800002383212A000000000000000001000000000000015600000000000156131111001915270200", JDialogSelect.tbindex, 1);
         jTable1.getModel().setValueAt("通用指令--GPO指令", JDialogSelect.tbindex, 2);
         JDialogSelect.tbindex++;
    }//GEN-LAST:event_jBreadcashActionPerformed

    private void jBTlvAnsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBTlvAnsActionPerformed
        // TODO add your handling code here:
        String str=System.getProperty("user.dir");
        str+="\\postool\\EMV TLV查询分析器.exe";
        try{
         Runtime.getRuntime().exec(str);
         jTlog.append(str+"加载成功!\r\n");
        
        }catch(Exception e)
        {
            jTlog.append(str+"加载失败!\r\n");
        }
    }//GEN-LAST:event_jBTlvAnsActionPerformed

    private void jBSavelogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBSavelogActionPerformed
        // TODO add your handling code here:
   //     final JFileChooser fc = new JFileChooser();
        jFileChoose1=new javax.swing.JFileChooser();
        int returnVal = jFileChoose1.showDialog(this, "确定");
        if(returnVal==0)
        {
             String str=jFileChoose1.getSelectedFile().getPath();
             str+=".txt";
            try{
             java.io.FileOutputStream fos=new java.io.FileOutputStream(new java.io.File(str));
             java.io.OutputStreamWriter osw=new java.io.OutputStreamWriter(fos);  
             osw.write(jTcmd.getText());
             osw.flush();
             osw.close();
             jTlog.append(str+" 日志保存成功!\r\n");
            }catch(Exception e)
            {
                jTlog.append(e.toString());
            }
        }
    }//GEN-LAST:event_jBSavelogActionPerformed

    private void jBSavecmdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBSavecmdActionPerformed
        // TODO add your handling code here:
        jFileChoose1=new javax.swing.JFileChooser();
        int returnVal = jFileChoose1.showDialog(this, "确定");
        if(returnVal==0)
        {
             String str=jFileChoose1.getSelectedFile().getPath();
             str+=".txt";
            try{
                if(JDialogSelect.tbindex>0)
                {
                     int i;
                     java.io.FileOutputStream fos=new java.io.FileOutputStream(new java.io.File(str));
                     java.io.OutputStreamWriter osw=new java.io.OutputStreamWriter(fos,"GBK");  
                     for(i=0;i<JDialogSelect.tbindex;i++)
                     {
                          osw.write("#"+jTable1.getModel().getValueAt(i, 2).toString()+"\r\n");
                          osw.write(jTable1.getModel().getValueAt(i, 1).toString()+"\r\n");
                     }
                     osw.flush();
                     osw.close();
                     jTlog.append(str+" 命令保存成功!\r\n"); 
                }
             
            }catch(Exception e)
            {
                jTlog.append(e.toString());
            }
        }
    }//GEN-LAST:event_jBSavecmdActionPerformed

    private void jBLoadcmdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBLoadcmdActionPerformed
        // TODO add your handling code here:
        jFileChoose1=new javax.swing.JFileChooser();
        int returnVal = jFileChoose1.showDialog(this, "加载指令");
        if(returnVal==0)
        {
             String str=jFileChoose1.getSelectedFile().getPath();
             //str+=".txt";
             if(str.endsWith(".txt"))
             {
                try{

                    String encoding="GBK";
                    java.io.File file=new java.io.File(str);
                    if(file.isFile() && file.exists()) //判断文件是否存在
                    {
                        java.io.FileInputStream fis=new java.io.FileInputStream(file);
                        java.io.InputStreamReader fsr=new java.io.InputStreamReader(fis,encoding);  
                        java.io.BufferedReader reader = new java.io.BufferedReader(fsr);
                        String lineTxt;
                        JDialogSelect.tbindex=0;
                        while((lineTxt = reader.readLine()) != null){
                            
                            if(lineTxt.startsWith("#"))
                            {
                                jTable1.getModel().setValueAt(lineTxt.substring(1), JDialogSelect.tbindex, 2);    
                            }
                            else
                            {   
                                jTable1.getModel().setValueAt(JDialogSelect.tbindex, JDialogSelect.tbindex, 0);
                                jTable1.getModel().setValueAt(lineTxt, JDialogSelect.tbindex, 1);
                                JDialogSelect.tbindex++;
                            }  
                            jTlog.append(lineTxt+"\r\n");
                        }
                        fsr.close();
                        jTlog.append(str+" 命令加载成功!\r\n"); 
                    }
                    else
                    {
                        jTlog.append(str+" 找不到文件!\r\n");     
                    }

                }catch(Exception e)
                {
                    jTlog.append(e.toString());
                }
             }
        }
    }//GEN-LAST:event_jBLoadcmdActionPerformed

    private void jBclearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBclearActionPerformed
        // TODO add your handling code here:
        jTcmd.setText("");
    }//GEN-LAST:event_jBclearActionPerformed

    private void jBDESMACAnsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBDESMACAnsActionPerformed
        // TODO add your handling code here:
        String str=System.getProperty("user.dir");
        str+="\\postool\\Des.exe";
        try{
         Runtime.getRuntime().exec(str);
         jTlog.append(str+"加载成功!\r\n");
        
        }catch(Exception e)
        {
            jTlog.append(str+"加载失败!\r\n");
        }
    }//GEN-LAST:event_jBDESMACAnsActionPerformed

    private void jBRSAcalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBRSAcalActionPerformed
        // TODO add your handling code here:
        String str=System.getProperty("user.dir");
        str+="\\postool\\RSA.exe";
        try{
         Runtime.getRuntime().exec(str);
         jTlog.append(str+"加载成功!\r\n");
        
        }catch(Exception e)
        {
            jTlog.append(str+"加载失败!\r\n");
        }
    }//GEN-LAST:event_jBRSAcalActionPerformed

    private void jB8583bitmapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jB8583bitmapActionPerformed
        // TODO add your handling code here:
        String str=System.getProperty("user.dir");
        str+="\\postool\\8583位图工具.exe";
        try{
         Runtime.getRuntime().exec(str);
         jTlog.append(str+"加载成功!\r\n");
        
        }catch(Exception e)
        {
            jTlog.append(str+"加载失败!\r\n");
        }
    }//GEN-LAST:event_jB8583bitmapActionPerformed

    private void jBTCPtoolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBTCPtoolActionPerformed
        // TODO add your handling code here:
        String str=System.getProperty("user.dir");
        str+="\\postool\\SocketTestDlg.exe";
        try{
         Runtime.getRuntime().exec(str);
         jTlog.append(str+"加载成功!\r\n");
        
        }catch(Exception e)
        {
            jTlog.append(str+"加载失败!\r\n");
        }
    }//GEN-LAST:event_jBTCPtoolActionPerformed

    private void jBGetChallengeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBGetChallengeActionPerformed
        // TODO add your handling code here:
         jTable1.getModel().setValueAt(JDialogSelect.tbindex, JDialogSelect.tbindex, 0);
         jTable1.getModel().setValueAt("0084000004", JDialogSelect.tbindex, 1);
         jTable1.getModel().setValueAt("通用指令--取随机数", JDialogSelect.tbindex, 2);
         JDialogSelect.tbindex++;
    }//GEN-LAST:event_jBGetChallengeActionPerformed

    private void jBExternalAuthenticationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBExternalAuthenticationActionPerformed
        // TODO add your handling code here:
         jTable1.getModel().setValueAt(JDialogSelect.tbindex, JDialogSelect.tbindex, 0);
         jTable1.getModel().setValueAt("008200VE08MACXXXXXXXXXXXXX", JDialogSelect.tbindex, 1);
         jTable1.getModel().setValueAt("通用指令--外部验证", JDialogSelect.tbindex, 2);
         JDialogSelect.tbindex++;
    }//GEN-LAST:event_jBExternalAuthenticationActionPerformed

    private void jBReadEPActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBReadEPActionPerformed
        // TODO add your handling code here:
        jTable1.getModel().setValueAt(JDialogSelect.tbindex, JDialogSelect.tbindex, 0);
        jTable1.getModel().setValueAt("805C000204", JDialogSelect.tbindex, 1);
        jTable1.getModel().setValueAt("通用指令--读钱包余额", JDialogSelect.tbindex, 2);
        JDialogSelect.tbindex++;
    }//GEN-LAST:event_jBReadEPActionPerformed

    private void jBcutpicActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBcutpicActionPerformed
        // TODO add your handling code here:
        String str=System.getProperty("user.dir");
        str+="\\postool\\QQ截图.EXE";
        try{
         Runtime.getRuntime().exec(str);
         jTlog.append(str+"加载成功!\r\n");
        
        }catch(Exception e)
        {
            jTlog.append(str+"加载失败!\r\n");
        }
    }//GEN-LAST:event_jBcutpicActionPerformed

    private void jBt_8583ansActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBt_8583ansActionPerformed
        // TODO add your handling code here:
        String str=System.getProperty("user.dir");
        str+="\\postool\\中国银联报文分析工具\\中国银联报文分析.exe";
        try{
         Runtime.getRuntime().exec(str);
         jTlog.append(str+"加载成功!\r\n");
        
        }catch(Exception e)
        {
            jTlog.append(str+"加载失败!\r\n");
        }
    }//GEN-LAST:event_jBt_8583ansActionPerformed

    private void jBt_calcActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBt_calcActionPerformed
        // TODO add your handling code here
        String str=System.getProperty("user.dir");
        str+="\\postool\\calc.exe";
        try{
         Runtime.getRuntime().exec(str);
         jTlog.append(str+"加载成功!\r\n");
        
        }catch(Exception e)
        {
            jTlog.append(str+"加载失败!\r\n");
        }
    }//GEN-LAST:event_jBt_calcActionPerformed

    /**
     * @param args the command line arguments
     */
    public static final String PORT_NAME = "COM2";
    public static final String OS =  "window";//操作系统，可以是 window，linux
    MyPort sp = new MyPort();
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new NewJFrame().setVisible(true);
            }   
        });
    }
    
    private javax.swing.JFileChooser jFileChoose1;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jB8583bitmap;
    private javax.swing.JButton jBDESMACAns;
    private javax.swing.JButton jBExternalAuthentication;
    private javax.swing.JButton jBGetChallenge;
    private javax.swing.JButton jBLoadcmd;
    private javax.swing.JButton jBOpen;
    private javax.swing.JButton jBRSAcal;
    private javax.swing.JButton jBReadEP;
    private javax.swing.JButton jBSavecmd;
    private javax.swing.JButton jBSavelog;
    private javax.swing.JButton jBTCPtool;
    private javax.swing.JButton jBTlvAns;
    private javax.swing.JButton jBaddcmd;
    private javax.swing.JButton jBauto;
    private javax.swing.JButton jBcancel;
    private javax.swing.JButton jBclear;
    private javax.swing.JButton jBcutpic;
    private javax.swing.JButton jBreadcash;
    private javax.swing.JButton jBreadfile;
    private javax.swing.JButton jBreadrec;
    private javax.swing.JButton jBselcash;
    private javax.swing.JButton jBselect;
    private javax.swing.JButton jBstep;
    private javax.swing.JButton jBt_8583ans;
    private javax.swing.JButton jBt_calc;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton6;
    private javax.swing.JComboBox jCcom;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JToolBar.Separator jSeparator1;
    private javax.swing.JToolBar.Separator jSeparator10;
    private javax.swing.JToolBar.Separator jSeparator11;
    private javax.swing.JToolBar.Separator jSeparator2;
    private javax.swing.JToolBar.Separator jSeparator3;
    private javax.swing.JToolBar.Separator jSeparator4;
    private javax.swing.JToolBar.Separator jSeparator5;
    private javax.swing.JToolBar.Separator jSeparator6;
    private javax.swing.JToolBar.Separator jSeparator7;
    private javax.swing.JToolBar.Separator jSeparator8;
    private javax.swing.JToolBar.Separator jSeparator9;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTable1;
    public javax.swing.JTextArea jTcmd;
    private javax.swing.JTextArea jTlog;
    private javax.swing.JToolBar jToolBar1;
    // End of variables declaration//GEN-END:variables
}
